/*
 * @(#) AtRowData.java 2013-8-12 上午10:34:26
 *
 * Copyright 2013 Rockwell Automation, Inc. All rights reserved.
 * Rockwell Automation PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */package com.osi.mes.base.object;

import com.datasweep.compatibility.client.ATRow;
import com.datasweep.compatibility.ui.Time;

public abstract class AtRowData
{
	ATRow atRow;
	public AtRowData(ATRow atRow)
	{
		this.atRow = atRow;
	}
	
	public ATRow getAtRow()
	{
		return this.atRow;
	}
	
	public String toString(Object data)
	{
		return data == null? null:String.valueOf(data);
	}
	
	public Time toTime(Object data)
	{
		return data == null? null:(Time)data;
	}
	
	public Float toFloat(Object data)
	{
		if(data == null)
		{
			return (float) 0;
		}
		else
		{
			if(data instanceof Float)
			{
				return (Float) data;
			}
			else
			{
				return Float.valueOf(data.toString());
			}
		}
	}
	
	public Integer toInteger(Object data)
	{
		if(data == null)
		{
			return 0;
		}
		else
		{
			if(data instanceof Long)
			{
				return ((Long) data).intValue();
			}
			else
			{
				return Integer.valueOf(data.toString());
			}
		}
	}
	
}
